import { Controller, Get, Param, Post, Body, Delete } from '@nestjs/common';
import { UserService } from './user.service';

@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Get('info')
  getUserInfo() {
    return this.userService.findAll();
  }
  @Get('info/greater-than/:id')
  getUserInfoGreaterThanId(@Param() { id }) {
    return this.userService.queryUser(id);
  }

  @Get('info-count')
  getUserInfoAndCount() {
    return this.userService.findAllAndCount();
  }

  @Get('info/:id')
  getIdUser(@Param() params) {
    return this.userService.findOne(Number(params.id));
  }

  @Post('info')
  createUserInfo(@Body() body) {
    return this.userService.createUser(body);
  }

  @Delete('info/:id')
  deleteUserInfo(@Param() { id }) {
    return this.userService.delete(Number(id));
  }
}
